package com.qsmx.store.app.main.mem.adapter.coin;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.qsmx.store.app.main.mem.entity.MemCoinsEntity;
import com.qsmx.store.app.main.mem.entity.MemTicketEntity;

import java.util.List;

public class MemCoinContentAdapter extends ArrayAdapter {

    private int itemResourceId;
    private List<MemCoinsEntity> mCoinList;

    public void setList(List<MemCoinsEntity> mCoinList) {
        this.mCoinList = mCoinList;
    }

    public MemCoinContentAdapter(@NonNull Context context, @LayoutRes int resource) {
        super(context, resource);
        this.itemResourceId = resource;
    }

    @Override
    public int getCount() {
//            if (coinsList != null && coinsList.size() > 0) {
//                return coinsList.size();
//            } else {
//                return 0;
//            }

        return 20;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        View view;
        ViewHolder viewHolder;

//            MemCoinsEntity data = coinsList.get(position);

        if (convertView == null) {
            view = LayoutInflater.from(parent.getContext()).inflate(itemResourceId, parent, false);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            view = convertView;
            viewHolder = (ViewHolder) view.getTag();
        }

        return view;
    }

    private class ViewHolder {
        private TextView tvBusinessDay;
        private TextView tvModifyDate;
        private TextView tvType;
        private TextView tvOrderCoin;
        private TextView tvRealCoin;
        private TextView tvLastCoin;
        private TextView tvUploadStatus;

        ViewHolder(View itemView) {
//                tvBusinessDay = (TextView) itemView.findViewById(R.id.tv_business_day);
//                tvModifyDate = (TextView) itemView.findViewById(R.id.tv_modify_date);
//                tvType = (TextView) itemView.findViewById(R.id.tv_type);
//                tvOrderCoin = (TextView) itemView.findViewById(R.id.tv_order_coin);
//                tvRealCoin = (TextView) itemView.findViewById(R.id.tv_real_coin);
//                tvLastCoin = (TextView) itemView.findViewById(R.id.tv_last_coin);
//                tvUploadStatus = (TextView) itemView.findViewById(R.id.tv_upload_status);
        }
    }
}
